#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<int>s[500005];
int num,jl[25],k,ans;
void dfs1(int p,int fa,int dep,int pd){
    if(jl[p]) pd++;
    if(dep==k){
        if(pd==1&&num!=-1) num++;
        else num=-1;return;
    }
    for(int i=0;i<s[p].size();i++){
        int y=s[p][i];
        if(y==fa) continue;
        dfs1(y,p,dep+1,pd);
    }
}
void dfs(int p,int n){
    if(p>n){
        num=0;
        for(int i=1;i<=n;i++) dfs1(i,0,1,0);
        if(num>0){
            ans++;
            // for(int i=1;i<=n;i++) cout<<jl[i]<<" ";cout<<'\n';
        }
        return;
    }
    jl[p]=1;dfs(p+1,n),jl[p]=0,dfs(p+1,n);
}
int dp[500005][2];
const int mod=1e9+7;
signed main(){
    freopen("life.in","r",stdin);
    freopen("life.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int n;cin>>n>>k;
    for(int i=1;i<n;i++){
        int x,y;cin>>x>>y;
        s[x].push_back(y),s[y].push_back(x);
    }
    if(n<=18){
        dfs(1,n);
        if(ans>0) cout<<"YES"<<'\n'<<ans;
        else cout<<"NO"<<'\n'<<ans;return 0;
    }
    if(n<k) cout<<"NO"<<'\n'<<0;
    else
    cout<<"YES"<<'\n'<<k;
    return 0;
}